package net.jlnx.Uebung4_1.data;

import java.util.Vector;
import net.jlnx.Uebung4_1.util.FigurenHelper;

public class Figur {

	protected int X;
	protected int Y;
	protected int Z;
	private static Vector<Figur> figuren = new Vector<Figur>();

	// fuer uebung 4 - aufgabe 4
	protected double elementFlaeche = 0;

	public static final int anzFiguren() {
		return figuren.size();
	}

	public Figur(int posX, int posY, int posZ) {
		this.X = posX;
		this.Y = posY;
		this.Z = posZ;
		Figur.figuren.add(this);
	}

	public int getZIndex() {
		return this.Z;
	}

	public static Vector<Figur> getAlleFiguren() {
		return Figur.figuren;
	}

	public static Object[] getZSortierteFiguren() {
		Object[] xs = Figur.getAlleFiguren().toArray();
		FigurenHelper.bubbleSort(xs);
		return xs;
	}

	public static Vector<Figur> filterZ(int fromZ, int toZ, Object[] objects) {
		Vector<Figur> tmp = new Vector<Figur>();
		for (Object figur : objects) {
			if (((Figur) figur).getZIndex() >= fromZ
					&& ((Figur) figur).getZIndex() <= toZ) {
				tmp.add((Figur) figur);
			}
		}

		return tmp;
	}

	public double getElementFlaeche() {
		return this.elementFlaeche;
	}
}